If all the data of the variable in x
is to be extracted, simply use []
(unlike with regular arrays, this is required, otherwise the details of the
variable are printed on the console).
The indices into the axes to be subset can be specified in a variety of
ways; in practice it should (resolve to) be a vector of integers. A range
(e.g. 100:200
), an explicit vector (c(23, 46, 3, 45, 17
), a sequence
(seq(from = 78, to = 100, by = 2
), all work. Note, however, that only a
single range is generated from the vector so these examples resolve to
100:200
, 3:46
, and 78:100
, respectively. It is also possible to use a
custom function as an argument.
This method works with "bare" indices into the axes of the array. If
you want to use domain values of the axes (e.g. longitude values or
timestamps) to extract part of the variable array, use the
CFVariable$subset()
method.
Scalar axes should not be included in the indexing as they do not represent a
dimension into the data array.